var exeluploader;
$(function() {
	exeluploader = new qq.FineUploader({
		element: $('#file_btn')[0],
		text: {
			uploadButton: '浏览',
			cancelButton: '取消'
		},
		request: {
			endpoint: '../companyUser/upload'
		},
//		params : getFileParams,
		messages: {
			typeError: "文件类型错误,只能导入EXCEL文件",
			sizeError: "最大只能上传2M文件",
			minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
			emptyError: "{file} is empty, please select files again without it.",
			noFilesError: "请选择需要导入的文件",
			tooManyItemsError: "Too many items ({netItems}) would be uploaded.  Item limit is {itemLimit}.",
			retryFailTooManyItems: "Retry failed - you have reached your file limit.",
			onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
		},
		autoUpload: true,
		multiple: true,
		validation: {
			allowedExtensions: ['xlsx','xls'],
			sizeLimit: 10485760 // 10M
		},
		callbacks: {
			onSubmit:function(id,fileName){
				$("#fileName").val(fileName);
				$(".qq-upload-list").hide();
			},
			onComplete: function(id, fileName, responseJSON) {
				if(responseJSON.info){
					alert(responseJSON.info);
				}else if(responseJSON.result){
					$('#importWin').myWindow('close');
					$.myMessager.alert({'title':'温馨提示','msg':'<p><strong>成功导入'+responseJSON.result+'条客户信息!</strong></p>'});
				}else{
					$('#errorInfo').empty().append('<p><strong>导入失败,系统异常!</strong></p>');
				}
				
			}
		},
		debug: true
	});
});

function getFileParams() {
	return {"activityId":$("#acId").val()};
}